﻿@{
    ViewBag.Title = "用户列表";
    Layout = "~/Views/Shared/_Main.cshtml";
}@section Head{
<script type="text/javascript">
    var clickAll = true;
    var retArr = new Array();
    var ExpIDs = new Array();
    var opts = {
        rows: 10,
        height: 450,
        url: "/SysUser/GetList",
        para: {},
        idField: "Guid",
        checkbox: true,
        columns: [ 
                    { field: 'EmployeeName', title: '姓名', width: 15, sortable: true },
                    { field: 'Username', title: '用户名', width: 15, sortable: true },
                    { field: 'CompanyName', title: '公司', width: 35, sortable: true },
                    { field: 'OfficeTel', title: '办工电话', width: 15, sortable: true },
                    { field: 'OfficeEmail', title: 'Email', width: 20, sortable: true }
                    ],
        OnChickRow: function (value, rowData, rowIndex) {
            return clickRow(value, rowData, rowIndex, true);
        }
    };
    function clickRow(value, rowData, rowIndex, load) {
        $("#sel_content").append("<span class='s1 s1" + value + "'><a title='" + rowData.Username + "'>" + rowData.EmployeeName + "</a><span class='s2 s2" + value + "''>&nbsp;X&nbsp;</span></span>");
        $(".s2" + value).bind("click", function () {
            $(".s1" + value).remove();
            $(".s2" + value).remove();
            for (var j = 0; j < retArr.length; j++) {
                if (retArr[j].Guid == value) {
                    retArr.removeAt(j);
                }
            }
            ExpIDs.removeValue(value);
            opts.para["ExpIDs"] = ExpIDs.join(",");
            initTable("DataGrid", opts);
        });
        retArr.push(rowData);
        ExpIDs.push(value);
        
        if (load) {
            opts.para["ExpIDs"] = ExpIDs.join(",");
            initTable("DataGrid", opts);
        }
        return true;
    }
    $(function () {
        $("#DataGrid").dg(opts);
    });
    function btnSearch() {
        opts.para["EmployeeCode"] = "";
        opts.para["EmployeeName"] = $.trim($("#txt_EmployeeName").val());
        opts.para["UserName"] = $.trim($("#txt_UserName").val());
        thisPageNum = 1;
        $("#DataGrid").dg(opts);
    }
    function flexiSelect() {
        if (retArr.length < 1) {
            alert('请选择一条数据!');
            return false;
        }
        returnParent(retArr);
        return false;
    }
</script>
}
<div style="height: 470px; padding-left: 5px; padding-right: 5px; overflow-y: scroll;">
    <table class="listTitle">
        <tr>
            <td width="15">
                <img src="/images/search.png" />
            </td>
            <td width="300">
                用户列表搜索
            </td>
            <td align="right">
            </td>
        </tr>
    </table>
    <table class="searchArea" width="100%">
        <tr>
            <td> 
                <input type="hidden" id="txt_EmployeeCode" />
                姓名：
                <input type="text" id="txt_EmployeeName" />
                用户名：
                <input type="text" id="txt_UserName" /> 
                <input type="button" value="搜索" class="button" onclick="btnSearch()" />
            </td>
        </tr>
    </table>
    <table id="selected" style="width: 100%;">
        <tr>
            <td width="50">
                已选择：
            </td>
            <td>
                <div id="sel_content">
                </div>
            </td>
            <td width="50">
                <input type="button" value=" 确定 " class="button" onclick="flexiSelect()" />
            </td>
        </tr>
    </table>
    <table class="listTitle">
        <tr>
            <td width="15">
                <img src="/images/filesave.png" />
            </td>
            <td width="300">
                用户列表<span id="type_Name"></span>
            </td>
            <td align="right">
            </td>
        </tr>
    </table>
    <table id="DataGrid" class="pagTable" cellpadding="0" cellspacing="0">
    </table>
    <div>
        <div id="Pagination" class="pagination">
        </div>
        <div id="loading" class="loading">
            <img src="/Images/tree_loading.gif" />
        </div>
    </div>
    <div id="msg">
    </div>
</div>
